package com.nightcolor.im.view;

import com.nightcolor.im.HorizontalLvTest;
import com.nightcolor.im.framework.ScrolledMainView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Gallery;

public class AdGallery extends Gallery {

	private ScrolledMainView mMainView;
	private int mCurPage;
	private int mLastMotionX;
	private boolean mIsMenuOpen = false;
	
	public AdGallery(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
		// TODO Auto-generated constructor stub
	}

	public AdGallery(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
		// TODO Auto-generated constructor stub
	}

	public AdGallery(Context context) {
		super(context);
		init();
		// TODO Auto-generated constructor stub
	}
	
	public void setScrolledMainView(ScrolledMainView view) {
		mMainView = view;
	}
	
	public void setCurPage(int curPage) {
		mCurPage = curPage;
	}
	
	public void setMenuOpen(boolean isMenuOpen) {
		mIsMenuOpen = isMenuOpen;
	}
	
	private void init() {
		
	}

	
	
	@Override
	public boolean onInterceptTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		int action = event.getAction();
		int x = (int)event.getX();
		
		if (action == MotionEvent.ACTION_DOWN) {
			mLastMotionX = x;
		}
		else if (action == MotionEvent.ACTION_MOVE) {
			int deltaX = x - mLastMotionX;
			if (deltaX > 0 && mCurPage == 0) {
			}
			else {
			}
			mLastMotionX = x;
		}
		else if (action == MotionEvent.ACTION_UP 
				|| action == MotionEvent.ACTION_CANCEL) {
		}
		return super.onInterceptTouchEvent(event);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		int action = event.getAction();
		int x = (int)event.getX();
		
		if (action == MotionEvent.ACTION_DOWN) {
			mLastMotionX = x;
		}
		else if (action == MotionEvent.ACTION_MOVE) {
			int deltaX = x - mLastMotionX;
			if (deltaX > 0 && mCurPage == 0) {
			}
			else {
			}
			mLastMotionX = x;
		}
		else if (action == MotionEvent.ACTION_UP 
				|| action == MotionEvent.ACTION_CANCEL) {
		}
		
		return super.onTouchEvent(event);
	}
	
}
